package com.zmc.lostfound.auth.vo;

import com.zmc.lostfound.common.valid.AddGroup;
import com.zmc.lostfound.common.valid.UpdateGroup;
import com.zmc.lostfound.common.valid.ValueIntList;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

import static com.zmc.lostfound.common.constant.RegexConstant.*;

/**
 * @author zmc
 * @description 管理员新增/修改用户基本信息请求体
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("管理员新增/修改用户基本信息请求体")
public class UserSaveWithAdminVO implements Serializable {

    private static final long serialVersionUID = 1507044780470429091L;

    /**
     * 用户id
     */
    @ApiModelProperty("用户id")
    @Null(message = "新增用户信息: 用户id必须为空", groups = {AddGroup.class})
    @NotNull(message = "修改用户信息: 用户id不能为空", groups = {UpdateGroup.class})
    @Min(value = 1, message = "修改用户信息: 用户id必须大于等于1", groups = {UpdateGroup.class})
    private Long id;

    /**
     * 手机号
     */
    @ApiModelProperty("手机号")
    @NotBlank(message = "新增用户信息: 手机号不能为空", groups = {AddGroup.class})
    @Pattern(regexp = PHONE_REGEX, message = "手机号格式错误", groups = {AddGroup.class, UpdateGroup.class})
    private String phone;

    /**
     * 邮箱
     */
    @ApiModelProperty("邮箱")
    @Pattern(regexp = EMAIL_REGEX, message = "QQ邮箱格式错误", groups = {AddGroup.class, UpdateGroup.class})
    private String qqEmail;

    /**
     * 登录密码
     */
    @ApiModelProperty("登录密码")
    @Pattern(regexp = PASSWORD_REGEX, message = "登录密码限制为6~18个字符，至少包含1个字母、1个数字、1个特殊字符", groups = {AddGroup.class, UpdateGroup.class})
    private String password;

    /**
     * 昵称
     */
    @ApiModelProperty("昵称")
    @Length(min = 1, max = 15, message = "昵称长度限制为1~15个字符", groups = {AddGroup.class, UpdateGroup.class})
    private String nickname;

    /**
     * 头像访问链接
     */
    @ApiModelProperty("头像访问链接")
    @URL(message = "头像访问链接不合法", groups = {AddGroup.class, UpdateGroup.class})
    private String imgUrl;

    /**
     * 性别(0：女；1：男)
     */
    @ApiModelProperty("性别(0：女；1：男)")
    @ValueIntList(values = {0, 1}, message = "性别只能为0或1[0:女，1:男]", groups = {AddGroup.class, UpdateGroup.class})
    private Integer sex;

}
